#include<iostream>
using namespace std;
const int N = 2e5 + 10;
int h[N], ne[N], e[N], idx;
int n;
int f[N];
void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}
void dfs(int u, int fa)
{
	f[u] = 1;
	for (int i = h[u]; ~i; i = ne[i]) {
		int j = e[i];
		if (j != fa) {
			dfs(j, u);
			f[u] += f[j];
		}
	}
}
int main()
{
	cin >> n;
	memset(h, -1, sizeof(h));
	for (int i = 2; i <= n; i++) {
		int x;
		cin >> x;
		add(i, x);
		add(x, i);
	}
	dfs(1, -1);
	for (int i = 1; i <= n; i++) {
		cout << f[i] << " ";
	}
	return 0;
}
